#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef pair < ll , ll > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 5e5 + 10;

ll n, a[N], base, sg, two, zero;
set < pii > one;

void solve() {
	n = in; rep(i, 1, n) a[i] = in;
	zero = 0; two = -1; base = 0; sg = 1; one.clear();
	rep(i, 1, n) {
		if(~two) {
			zero += 2; one.clear(); base = 0; sg = 1; if(a[i] > two) one.insert({ a[i] - two, a[i] - two }); 
		} else if(one.size()) {
			if(sg == 1) {
				while(one.size() && base + one.rbegin() -> fi >= a[i]) one.erase(*one.rbegin());
				if(one.size() && base + one.rbegin() -> se >= a[i]) {
					ll l = one.rbegin() -> fi;
					one.erase(*one.rbegin());
					one.insert({ l, a[i] - base - 1 });
				} 
			} else {
				while(one.size() && base - one.begin() -> se >= a[i]) one.erase(one.begin());
				if(one.size() && base - one.begin() -> fi >= a[i]) {
					ll r = one.begin() -> se;
					one.erase(one.begin());
					one.insert({ base - a[i] + 1, r});
				}
			}
			zero++; base = a[i] - base; sg = -sg;
		} else {
			base = a[i]; sg = -1; if(i > 1) one.insert({ 1, min(a[i], a[i - 1]) - 1 });
		}
		two = -1; if(a[i] & 1) continue;
		bool fl = false;
		ll t = a[i] / 2, ct = (t - base) / sg;
		auto it = one.lower_bound({ ct + 1, ct + 1 });
		if(it != one.begin()) {
			it--;
			if(it -> fi <= ct && it -> se >= ct) {
				int l = it -> fi, r = it -> se; one.erase(it);
				if(l != ct) one.insert({ l, ct - 1 });
				if(r != ct) one.insert({ ct + 1, r });
				two = t; fl = true;
			}
		}
		if(!fl) one.insert({ ct, ct });
	}
	if(~two) printf("%lld\n", n * 2 - zero - 2);
	else if(one.size()) printf("%lld\n", n * 2 - zero - 1);
	else printf("%lld\n", n * 2 - zero);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    int T = in; while(T--) solve(); return 0;
}
